const initState = {
  count: 5,
  name: "tom",
};

const reducer = (state = initState, action) => {
  console.log(action);
  switch (action.type) {
    case "increment":
      return {
        ...state,
        count: state.count + action.n,
      };
    case "decrement":
      return {
        ...state,
        count: state.count - 1,
      };
    case "changeName":
      return {
        ...state,
        name: action.name,
      };
    default:
      return state;
  }
};

export default reducer;
